home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / music4c.sit / Music4C Folder / Sources Folder / Preferences.c < prev    next >
Text File  |  1990-06-19  |  18KB  |  776 lines

  1. /*
  2. * ⌐ Graeme Gerrard 1990
  3. * Faculty of Music, University of Melbourne
  4. * Parkville Victoria 3052 Australia.
  5. *
  6. * ARPANET: grae@murdu.ucs.unimelb.edu.au
  7. * telephone: (613) 344 4127, Fax: (613) 344 5346
  8. */
  9. #include "Music4C.h"
  10. #include "Preferences_Dialog.h"
  11. #include "Music4C_Prototype.h"
  12. #include "string.h"
  13.  
  14. void  GetMusic4C_Prefs(void);
  15.  
  16. static pascal char  MyFilter (DialogPtr   theDialog, 
  17.         EventRecord   *theEvent,  short  *itemHit);
  18.  
  19. static void  Refresh_Dialog(DialogPtr    GetSelection);
  20. void  SaveMusic4C_Prefs(void);
  21. void  A_ErrorAlert(void);
  22.  
  23. #define  I_OK   1
  24. #define  I_Cancel   2
  25. #define  I_Pass1   3
  26. #define  I_Pass2   4
  27. #define  I_Pass3   5
  28.  
  29. #define        Pass1Test    1
  30. #define        Pass2Test    2
  31. #define        Pass3Test    3
  32. #define        Synthesize    4
  33.  
  34. static char   ExitDialog; 
  35. static Point   myPt; 
  36. static char   ChangedSelection; 
  37. static MenuHandle   tempMenu; 
  38. static long    Result; 
  39. static short   Popup_I_Run_Up_To;
  40. static short   Popup_I_Sound_File_Format;
  41. static short   Initial_Report_Flags;
  42.  
  43. /* ********************************************* */
  44. extern        int            RunUpTo;
  45. extern        int            ReportFlags;
  46. extern        Boolean        CreateSoundFile;
  47. extern        int            RunToPass1;        /* test pass1 only */
  48. extern        int            RunToPass2;        /* test up to pass2 only */
  49. extern        int            RunToPass3;        /* test pass3 only, i.e. don't write sample file */
  50. extern        int            SFoutputType;
  51. extern        OSErr        theErr;
  52.  
  53. extern        int            out1_flag;        /* pass1 output flag */
  54. extern        int            out2_flag;        /* pass2 output flag */
  55. extern        int            out3_flag;        /* pass3 output flag */
  56.  
  57.  
  58.  
  59.  
  60. void GetMusic4C_Prefs()
  61. {
  62.     int            refNum;
  63.     StringPtr    volName;
  64.     char        buffer[2];
  65.     long        count;
  66.     extern        Str255        FileFormat;
  67.     extern        Str255        SFDirectoryName;
  68.     extern        SysEnvRec    SysEnvData;
  69.     int    i;
  70.     
  71. /* "Music4C_Prefs" is kept in the System Folder */
  72.  
  73.     theErr = FSOpen("\pMusic4C_Prefs", SysEnvData.sysVRefNum, &refNum);
  74.     if (theErr) {
  75.         theErr = Create("\pMusic4C_Prefs", SysEnvData.sysVRefNum, 'MU4C', 'TEXT');
  76.         if ( theErr ) {    /* call Error Alert */
  77.             ParamText("\pCan't create Preferences file", NIL, NIL, NIL);
  78.             A_ErrorAlert();
  79.         }
  80.         theErr = FSOpen("\pMusic4C_Prefs", SysEnvData.sysVRefNum, &refNum);
  81.         /* we have created & opened the file, write in the default prefs */
  82.         buffer[0] = ReportFlags;
  83.         buffer[1] = RunUpTo;
  84.         count = 2L;
  85.         theErr = FSWrite( refNum, &count, &buffer);
  86.  
  87.         count = sizeof(FileFormat);
  88.         theErr = FSWrite( refNum, &count, &FileFormat); /* default SF format */
  89.         
  90.         count = sizeof(SFDirectoryName);
  91.         theErr = FSWrite( refNum, &count, &SFDirectoryName); /* default SF dir */
  92.  
  93.         if ( theErr != noErr ) {
  94.             ParamText("\pError writing Preferences file", NIL, NIL, NIL);
  95.             A_ErrorAlert();
  96.         }
  97.         volName = NIL;
  98.         theErr = FlushVol (volName,  SysEnvData.sysVRefNum);
  99.         theErr = FSClose(refNum);
  100.         theErr = FSOpen("\pMusic4C_Prefs", SysEnvData.sysVRefNum, &refNum);
  101.     }
  102.     /* prefs file is open */
  103.     count = 2L;
  104.     theErr = FSRead (refNum, &count, &buffer);
  105.     if ( theErr != noErr ) {
  106.         ParamText("\pError reading Preferences file", NIL, NIL, NIL);
  107.         A_ErrorAlert();
  108.     }
  109.     ReportFlags = (int)buffer[0];
  110.     RunUpTo = (int)buffer[1];
  111.     
  112.     
  113.     count = sizeof(FileFormat);
  114.     theErr = FSRead (refNum, &count, &FileFormat);
  115.     if ( theErr != noErr ) {
  116.         ParamText("\pError reading Preferences file", NIL, NIL, NIL);
  117.         A_ErrorAlert();
  118.     }
  119.  
  120.     PtoCstr((char *)FileFormat);
  121.     if ( (i = strcmp((char *)FileFormat, "AIFF")) == 0 )
  122.         SFoutputType = AIFF;
  123.     else if ( (i = strcmp((char *)FileFormat, "FLOAT")) == 0 )
  124.         SFoutputType = FLOAT;
  125.     else if ( (i = strcmp((char *)FileFormat, "Sound Designer")) == 0 )
  126.         SFoutputType = SD;
  127.     else if ( (i = strcmp((char *)FileFormat, "INT16")) == 0 )
  128.         SFoutputType = INT16;
  129.     else { /* default */
  130.         strcpy((char *)FileFormat, "FLOAT");
  131.         SFoutputType = FLOAT;
  132.     }
  133.     CtoPstr((char *)FileFormat);
  134.     
  135.     
  136.     count = sizeof(SFDirectoryName);
  137.     theErr = FSRead (refNum, &count, &SFDirectoryName);
  138.     if ( theErr != noErr ) {
  139.         ParamText("\pError reading Preferences file", NIL, NIL, NIL);
  140.         A_ErrorAlert();
  141.     }
  142.     theErr = FSClose(refNum);
  143.     
  144.     CreateSoundFile = FALSE;
  145.     RunToPass1 = 0;
  146.     RunToPass2 = 0;
  147.     RunToPass3 = 0;
  148.     switch( RunUpTo) {
  149.         case Synthesize:
  150.             CreateSoundFile = TRUE;
  151.             break;
  152.         case Pass3Test:
  153.             RunToPass3 = 1;
  154.             break;
  155.         case Pass2Test:
  156.             RunToPass2 = 1;
  157.             break;
  158.         case Pass1Test:
  159.             RunToPass1 = 1;
  160.             break;
  161.     }
  162.     
  163.     out1_flag = 0;
  164.     out2_flag = 0;
  165.     out3_flag = 0;
  166.     
  167.     if( ReportFlags & 4 )
  168.         out3_flag = 1;
  169.     if ( ReportFlags & 2 )
  170.         out2_flag = 1;
  171.     if ( ReportFlags & 1 )
  172.         out1_flag = 1;
  173. }
  174.  
  175.  
  176.  
  177.  
  178. void        SaveMusic4C_Prefs()
  179. {
  180.     int            refNum;
  181.     StringPtr    volName;
  182.     char        buffer[2];
  183.     long        count;
  184.     extern        Str255        FileFormat;
  185.     extern        Str255        SFDirectoryName;
  186.     
  187.     theErr = FSOpen("\pMusic4C_Prefs", SysEnvData.sysVRefNum, &refNum);
  188.     if (theErr) {
  189.         theErr = Create("\pMusic4C_Prefs", SysEnvData.sysVRefNum, 'MU4C', 'TEXT');
  190.         if ( theErr ) {    /* call Error Alert */
  191.             ParamText("\pCan't create Preferences file", NIL, NIL, NIL);
  192.             A_ErrorAlert();
  193.         }
  194.         theErr = FSOpen("\pMusic4C_Prefs", SysEnvData.sysVRefNum, &refNum);
  195.     }
  196.     /* we have created & opened the file, write in the prefs */
  197.     buffer[0] = ReportFlags;
  198.     buffer[1] = RunUpTo;
  199.     count = 2L;
  200.     theErr = FSWrite( refNum, &count, &buffer);
  201.  
  202.     count = sizeof(FileFormat);
  203.     theErr = FSWrite( refNum, &count, &FileFormat); /* default SF format */
  204.     
  205.     count = sizeof(SFDirectoryName);
  206.     theErr = FSWrite( refNum, &count, &SFDirectoryName);
  207.  
  208.     if ( theErr != noErr ) {
  209.         ParamText("\pError writing Preferences file", NIL, NIL, NIL);
  210.         A_ErrorAlert();
  211.     }
  212.     volName = NIL;
  213.     theErr = FlushVol (volName,  SysEnvData.sysVRefNum);
  214.      theErr = FSClose(refNum);
  215. }
  216.  
  217.  
  218.  
  219.  
  220. static pascal char  MyFilter (theDialog, theEvent, itemHit)
  221.     DialogPtr   theDialog; 
  222.     EventRecord   *theEvent;
  223.     short  *itemHit; 
  224. {
  225.     KeyMap    theKeys;
  226.     Rect   tempRect; 
  227.     char   xMyFilter; 
  228.      long    keyCode, charCode;
  229.      
  230.     xMyFilter = FALSE;
  231.     if (theEvent->what == mouseDown) 
  232.     {
  233.         myPt = theEvent->where; 
  234.         GlobalToLocal(&myPt); 
  235.          
  236.         
  237.         SetRect(&tempRect, 160,70,377,90);
  238.         if (PtInRect(myPt,&tempRect) == TRUE)
  239.         {
  240.             *itemHit = 999;
  241.             xMyFilter = TRUE;
  242.         }
  243.         
  244.         SetRect(&tempRect, 120,110,378,130);
  245.         if (PtInRect(myPt,&tempRect) == TRUE)
  246.         {
  247.             *itemHit = 999;
  248.             xMyFilter = TRUE;
  249.         }
  250.          
  251.     }
  252.     else if ( theEvent->what == keyDown ) {
  253.         charCode = BitAnd(theEvent->message, charCodeMask);
  254.         if ( charCode == 0x0D ) {
  255.             SetRect(&tempRect, 240, 168, 320, 188);
  256.             InvertRect(&tempRect);
  257.             *itemHit = I_OK;
  258.             xMyFilter = TRUE;
  259.         }
  260.         else {
  261.         /* got some other keydown */
  262.             *itemHit = 999;
  263.         }
  264.     }
  265.     else
  266.         *itemHit = 999;
  267.         
  268.     return(xMyFilter);
  269. }
  270.  
  271.  
  272. static void  Refresh_Dialog(GetSelection) 
  273.     DialogPtr    GetSelection;
  274.     Rect    tempRect;
  275.     short    DType;
  276.     Handle    DItem;
  277.     ControlHandle    CItem;
  278.     Rect    theRect;
  279.  
  280.     GetDItem(GetSelection,I_OK, &DType, &DItem, &tempRect);
  281.     PenSize(3, 3);
  282.     InsetRect(&tempRect, -4, -4);
  283.     FrameRoundRect(&tempRect, 16, 16); 
  284.     PenSize(1, 1); 
  285.     
  286.     TextFont(systemFont);
  287.     TextSize(12);
  288.     MoveTo(165,84);
  289.     DrawString("\pRun Up To: ");
  290.     SetRect(&tempRect,238,71,370,88);
  291.     EraseRect(&tempRect);
  292.     MoveTo(251,84);
  293.     switch (Popup_I_Run_Up_To)
  294.     {
  295.         case Pass1Test: 
  296.             DrawString("\pPass1 Test");
  297.             /* disable pass2 & 3, Popup_I_Sound_File_Format */
  298.             GetDItem(GetSelection, I_Pass2, &DType, &DItem, &theRect);
  299.             CItem = (ControlHandle)DItem;
  300.             HiliteControl(CItem, 255);
  301.             DisableItem(GetSelection, I_Pass2);
  302.             SetCtlValue(CItem, 0);
  303.             
  304.             GetDItem(GetSelection, I_Pass3, &DType, &DItem, &theRect);
  305.             CItem = (ControlHandle)DItem;
  306.             HiliteControl(CItem, 255);
  307.             DisableItem(GetSelection, I_Pass3);
  308.             SetCtlValue(CItem, 0);
  309.             
  310.             tempMenu = GetMenu(52);
  311.             if ( tempMenu != NIL ) {
  312.                 InsertMenu(tempMenu,-1);
  313.                 DisableItem(tempMenu, 0);
  314.             }
  315.             break;
  316.         case Pass2Test: 
  317.             DrawString("\pPass2 Test");
  318.             GetDItem(GetSelection, I_Pass2, &DType, &DItem, &theRect);
  319.             CItem = (ControlHandle)DItem;
  320.             HiliteControl(CItem, 0);
  321.             EnableItem(GetSelection, I_Pass2);
  322.             if ( ReportFlags & 2)
  323.                 SetCtlValue(CItem, 1);
  324.             else
  325.                 SetCtlValue(CItem, 0);
  326.             
  327.             GetDItem(GetSelection, I_Pass3, &DType, &DItem, &theRect);
  328.             CItem = (ControlHandle)DItem;
  329.             HiliteControl(CItem, 255);
  330.             DisableItem(GetSelection, I_Pass3);
  331.             SetCtlValue(CItem, 0);
  332.             
  333.             tempMenu = GetMenu(52);
  334.             if ( tempMenu != NIL ) {
  335.                 InsertMenu(tempMenu,-1);
  336.                 DisableItem(tempMenu, 0);
  337.             }
  338.             break;
  339.         case Pass3Test: 
  340.             DrawString("\pPass3 Test");
  341.             GetDItem(GetSelection, I_Pass2, &DType, &DItem, &theRect);
  342.             CItem = (ControlHandle)DItem;
  343.             HiliteControl(CItem, 0);
  344.             if ( ReportFlags & 2)
  345.                 SetCtlValue(CItem, 1);
  346.             else     
  347.                 SetCtlValue(CItem, 0);
  348.             
  349.             GetDItem(GetSelection, I_Pass3, &DType, &DItem, &theRect);
  350.             CItem = (ControlHandle)DItem;
  351.             HiliteControl(CItem, 0);
  352.             if ( ReportFlags >= 4)
  353.                 SetCtlValue(CItem, 1);
  354.             else     
  355.                 SetCtlValue(CItem, 0);
  356.             
  357.             EnableItem(GetSelection, I_Pass2);
  358.             EnableItem(GetSelection, I_Pass3);
  359.             tempMenu = GetMenu(52);
  360.             if ( tempMenu != NIL ) {
  361.                 InsertMenu(tempMenu,-1);
  362.                 DisableItem(tempMenu, 0);
  363.             }
  364.             break;
  365.         case Synthesize: 
  366.             DrawString("\pCreate Sound File");
  367.             GetDItem(GetSelection, I_Pass2, &DType, &DItem, &theRect);
  368.             CItem = (ControlHandle)DItem;
  369.             HiliteControl(CItem, 0);
  370.             if ( ReportFlags & 2)
  371.                 SetCtlValue(CItem, 1);
  372.             else     
  373.                 SetCtlValue(CItem, 0);
  374.             
  375.             GetDItem(GetSelection, I_Pass3, &DType, &DItem, &theRect);
  376.             CItem = (ControlHandle)DItem;
  377.             HiliteControl(CItem, 0);
  378.             if ( ReportFlags >= 4)
  379.                 SetCtlValue(CItem, 1);
  380.             else     
  381.                 SetCtlValue(CItem, 0);
  382.  
  383.             tempMenu = GetMenu(52);
  384.             if ( tempMenu != NIL ) {
  385.                 InsertMenu(tempMenu,-1);
  386.                 EnableItem(tempMenu, 0);
  387.             }
  388.             EnableItem(GetSelection, I_Pass2);
  389.             EnableItem(GetSelection, I_Pass3);
  390.             break;
  391.         default:
  392.             DrawString("\p????");
  393.             break;
  394.     }
  395.     
  396.     FrameRect(&tempRect);
  397.     MoveTo(tempRect.left + 1, tempRect.bottom);
  398.     LineTo(tempRect.right, tempRect.bottom);
  399.     LineTo(tempRect.right, tempRect.top + 1);
  400.     
  401.     TextFont(systemFont);
  402.     TextSize(12);
  403.     TextFont(systemFont);
  404.     TextSize(12);
  405.     MoveTo(125,124);
  406.     DrawString("\pSound File Format: ");
  407.     SetRect(&tempRect,253,111,371,128);
  408.     EraseRect(&tempRect);
  409.     MoveTo(266,124);
  410.     if ( Popup_I_Run_Up_To == Synthesize ) {
  411.         switch (Popup_I_Sound_File_Format)
  412.         {
  413.             case AIFF: 
  414.                 DrawString("\pAIFF");
  415.                 break;
  416.             case FLOAT: 
  417.                 DrawString("\pFLOAT");
  418.                 break;
  419.             case INT16: 
  420.                 DrawString("\pINT16");
  421.                 break;
  422.             case SD: 
  423.                 DrawString("\pSound Designer");
  424.                 break;
  425.             default:
  426.                 DrawString("\p????");
  427.                 break;
  428.         }
  429.     }
  430.     FrameRect(&tempRect);
  431.     MoveTo(tempRect.left + 1, tempRect.bottom);
  432.     LineTo(tempRect.right, tempRect.bottom);
  433.     LineTo(tempRect.right, tempRect.top + 1);
  434.     
  435.     TextFont(systemFont);
  436.     TextSize(12);
  437. }
  438.  
  439.  
  440.  
  441. void   D_Preferences_Dialog()
  442. {
  443.     DialogPtr   GetSelection;
  444.     Rect           tempRect;
  445.     short        DType;
  446.     Handle        DItem;
  447.     ControlHandle    CItem;
  448.     short       itemHit;
  449.     short       temp;
  450.     int        i;
  451.      
  452.          
  453.     GetSelection = GetNewDialog(3, NIL, (WindowPtr)-1);
  454.      
  455.     tempRect.top = GetSelection->portRect.top;
  456.     tempRect.left = GetSelection->portRect.left;
  457.     tempRect.bottom = GetSelection->portRect.bottom;
  458.     tempRect.right = GetSelection->portRect.right;
  459.     tempRect.top = ((screenBits.bounds.bottom - screenBits.bounds.top) - (tempRect.bottom - tempRect.top)) / 2;
  460.     tempRect.left = ((screenBits.bounds.right - screenBits.bounds.left) - (tempRect.right - tempRect.left)) / 2;
  461.     MoveWindow(GetSelection, tempRect.left, tempRect.top, TRUE);
  462.      
  463.     ShowWindow(GetSelection);
  464.     SelectWindow(GetSelection);
  465.     SetPort(GetSelection);
  466.      
  467.      
  468.      
  469.     /* Setup initial conditions */
  470.      Popup_I_Run_Up_To = RunUpTo;
  471.      Popup_I_Sound_File_Format = SFoutputType;
  472.     Initial_Report_Flags = ReportFlags;
  473.  
  474.     /* report flags */
  475.     GetDItem(GetSelection,I_Pass3, &DType, &DItem, &tempRect);
  476.     CItem = (ControlHandle)DItem; 
  477.     if ( ReportFlags >= 4 && RunUpTo >= 3)
  478.         SetCtlValue(CItem, 1);
  479.     else     
  480.         SetCtlValue(CItem, 0);
  481.         
  482.         
  483.     GetDItem(GetSelection,I_Pass2, &DType, &DItem, &tempRect);
  484.     CItem = (ControlHandle)DItem; 
  485.     if ( ReportFlags & 2 && RunUpTo >= 2)
  486.         SetCtlValue(CItem, 1);
  487.     else     
  488.         SetCtlValue(CItem, 0);
  489.     
  490.     GetDItem(GetSelection,I_Pass1, &DType, &DItem, &tempRect);
  491.     CItem = (ControlHandle)DItem; 
  492.     if ( ReportFlags & 1 && RunUpTo >= 1)
  493.         SetCtlValue(CItem, 1);
  494.     else     
  495.         SetCtlValue(CItem, 0);
  496.         
  497.     
  498.     
  499.     Refresh_Dialog(GetSelection); 
  500.      
  501.     ExitDialog = FALSE; 
  502.      
  503.     do {
  504.         ModalDialog(&MyFilter, &itemHit); 
  505.         GetDItem(GetSelection, itemHit, &DType, &DItem, &tempRect);
  506.         CItem = (ControlHandle)DItem; 
  507.          
  508.         /* Handle it real time */
  509.         if (itemHit == I_OK ) {
  510.             RunUpTo = Popup_I_Run_Up_To;
  511.             SFoutputType = Popup_I_Sound_File_Format;
  512.             Initial_Report_Flags = ReportFlags;
  513.             ExitDialog =TRUE;
  514.             Refresh_Dialog(GetSelection); 
  515.         }
  516.         
  517.         if (itemHit == I_Cancel )
  518.         {
  519.             Popup_I_Run_Up_To = RunUpTo;
  520.             Popup_I_Sound_File_Format = SFoutputType;
  521.             ReportFlags = Initial_Report_Flags;
  522.             ExitDialog =TRUE;
  523.         }
  524.         
  525.         if (itemHit == I_Pass3 )
  526.         {
  527.             temp = GetCtlValue(CItem);
  528.             SetCtlValue(CItem, ((temp + 1) & 1));
  529.             temp = GetCtlValue(CItem);
  530.             if ( temp ) {
  531.                 if ( ReportFlags < 4 )
  532.                     ReportFlags += 4;
  533.             }
  534.             else {
  535.                 if ( ReportFlags >= 4 )
  536.                     ReportFlags -= 4;
  537.             }
  538.         }
  539.         
  540.         if (itemHit == I_Pass2 )
  541.         {
  542.             temp = GetCtlValue(CItem);
  543.             SetCtlValue(CItem, ((temp + 1) & 1));
  544.             temp = GetCtlValue(CItem);
  545.             if ( temp ) {
  546.                 if ( !(ReportFlags & 2) )
  547.                     ReportFlags += 2;
  548.             }
  549.             else {
  550.                 if ( ReportFlags & 2 )
  551.                     ReportFlags -= 2;
  552.             }
  553.         }
  554.         
  555.         if (itemHit == I_Pass1 )
  556.         {
  557.             temp = GetCtlValue(CItem);
  558.             SetCtlValue(CItem, ((temp + 1) & 1));
  559.             temp = GetCtlValue(CItem);
  560.             if ( temp ) {
  561.                 if ( !(ReportFlags & 1) )
  562.                     ReportFlags += 1;
  563.             }
  564.             else {
  565.                 if ( ReportFlags & 1 )
  566.                     ReportFlags & 1;
  567.             }
  568.         }
  569.         
  570.         
  571.         SetRect(&tempRect, 160,70,377,90);
  572.         if ((PtInRect(myPt,&tempRect) == TRUE) && (itemHit == 999))
  573.         {
  574.             ChangedSelection = FALSE;
  575.             TextFont(systemFont);
  576.             TextSize(12);
  577.             
  578.             tempMenu= GetMenu(53);
  579.             if (tempMenu != NIL)
  580.             {
  581.                 InsertMenu (tempMenu,-1);
  582.                 SetRect(&tempRect,160,72,238,88);
  583.                 InvertRect(&tempRect);
  584.                 myPt.v  = 72;
  585.                 myPt.h  = 238;
  586.                 LocalToGlobal(&myPt);
  587.                 
  588.                 CheckItem(tempMenu,Popup_I_Run_Up_To,TRUE);
  589.                 for ( i = 1; i < 5; i ++ )
  590.                     if ( i !=     Popup_I_Run_Up_To )
  591.                         CheckItem(tempMenu,i,FALSE);
  592.                     else
  593.                         CheckItem(tempMenu,i,TRUE);
  594.                 Result = PopUpMenuSelect(tempMenu, myPt.v, myPt.h,  Popup_I_Run_Up_To);
  595.                 
  596.                 if ((Popup_I_Run_Up_To != LoWord(Result)) && (LoWord(Result) > 0))
  597.                 {
  598.                     CheckItem(tempMenu,Popup_I_Run_Up_To,FALSE);
  599.                     ChangedSelection = TRUE;
  600.                     Popup_I_Run_Up_To = LoWord(Result);
  601.                 }
  602.                 
  603.                 DeleteMenu(53);
  604.                 InvertRect(&tempRect);
  605.                 
  606.                 if (ChangedSelection == TRUE)
  607.                 {
  608.                     SetRect(&tempRect,240,72,369,87);
  609.                     EraseRect(&tempRect);
  610.                     
  611.                     MoveTo(tempRect.left + 12,tempRect.top + 12);
  612.                     switch (Popup_I_Run_Up_To)
  613.                     {
  614.                         case Pass1Test: 
  615.                                 DrawString("\pPass1 Test");
  616.                                 break;
  617.                         case Pass2Test: 
  618.                                 DrawString("\pPass2 Test");
  619.                                 break;
  620.                         case Pass3Test: 
  621.                                 DrawString("\pPass3 Test");
  622.                                 break;
  623.                         case Synthesize: 
  624.                                 DrawString("\pCreate Sound File");
  625.                                 break;
  626.                         default:
  627.                                 break;
  628.                     }
  629.                 }
  630.             }
  631.             TextFont(systemFont);
  632.             TextSize(12);
  633.         }
  634.         
  635.         
  636.         SetRect(&tempRect, 120,110,378,130);
  637.         if ((PtInRect(myPt,&tempRect) == TRUE) && (itemHit == 999))
  638.         {
  639.             ChangedSelection = FALSE;
  640.             TextFont(systemFont);
  641.             TextSize(12);
  642.             
  643.             tempMenu= GetMenu(52);
  644.             if (tempMenu != NIL)
  645.             {
  646.                 InsertMenu (tempMenu,-1);
  647.                 SetRect(&tempRect,120,112,253,128);
  648.                 InvertRect(&tempRect);
  649.                 myPt.v  = 112;
  650.                 myPt.h  = 253;
  651.                 LocalToGlobal(&myPt);
  652.             
  653.                 for ( i = 1; i < 5; i ++ )
  654.                     if ( i !=     Popup_I_Sound_File_Format )
  655.                         CheckItem(tempMenu,i,FALSE);
  656.                     else
  657.                         CheckItem(tempMenu,i,TRUE);
  658.                 Result = PopUpMenuSelect(tempMenu, myPt.v, myPt.h,  Popup_I_Sound_File_Format);
  659.                 
  660.                 if ((Popup_I_Sound_File_Format != LoWord(Result)) && (LoWord(Result) > 0))
  661.                 {
  662.                     CheckItem(tempMenu,Popup_I_Sound_File_Format,FALSE);
  663.                     ChangedSelection = TRUE;
  664.                     Popup_I_Sound_File_Format = LoWord(Result);
  665.                 }
  666.                 
  667.                 DeleteMenu(52);
  668.                 InvertRect(&tempRect);
  669.                 
  670.                 if (ChangedSelection == TRUE)
  671.                 {
  672.                     SetRect(&tempRect,255,112,370,127);
  673.                     EraseRect(&tempRect);
  674.                     
  675.                     MoveTo(tempRect.left + 12,tempRect.top + 12);
  676.                     switch (Popup_I_Sound_File_Format)
  677.                     {
  678.                         case AIFF: 
  679.                                 DrawString("\pAIFF");
  680.                                 break;
  681.                         case FLOAT: 
  682.                                 DrawString("\pFLOAT");
  683.                                 break;
  684.                         case INT16: 
  685.                                 DrawString("\pINT16");
  686.                                 break;
  687.                         case SD: 
  688.                                 DrawString("\pSound Designer");
  689.                                 break;
  690.                         default:
  691.                                 break;
  692.                     }
  693.                 }
  694.             }
  695.             TextFont(systemFont);
  696.             TextSize(12);
  697.         }         
  698.         Refresh_Dialog(GetSelection); 
  699.     } 
  700.     while (ExitDialog == FALSE);
  701.      
  702.      if ( itemHit != I_Cancel ) {
  703.          ReportFlags = 0;
  704.          out1_flag = 0;
  705.          out2_flag = 0;
  706.          out3_flag = 0;
  707.         /* Get results after dialog */
  708.         GetDItem(GetSelection,I_Pass3, &DType, &DItem, &tempRect);
  709.         CItem = (ControlHandle)DItem;
  710.         temp = GetCtlValue(CItem);
  711.         if ( (**CItem).contrlValue == 1) {
  712.             ReportFlags = 4;
  713.             out3_flag = 1;
  714.         }
  715.             
  716.         GetDItem(GetSelection,I_Pass2, &DType, &DItem, &tempRect);
  717.         CItem = (ControlHandle)DItem;
  718.         temp = GetCtlValue(CItem);
  719.         if ( (**CItem).contrlValue == 1) {
  720.             ReportFlags += 2;
  721.             out2_flag = 1;
  722.         }
  723.         
  724.         GetDItem(GetSelection,I_Pass1, &DType, &DItem, &tempRect);
  725.         CItem = (ControlHandle)DItem;
  726.         temp = GetCtlValue(CItem);
  727.         if ( (**CItem).contrlValue == 1) {
  728.             ReportFlags += 1;
  729.             out1_flag = 1;
  730.         }
  731.     }
  732.     
  733.         
  734.     DisposDialog(GetSelection); 
  735.     switch (Popup_I_Sound_File_Format) {
  736.         case    SD:
  737.             PstringCopy((char *)FileFormat, "\pSound Designer");
  738.             break;
  739.         case    AIFF:
  740.             PstringCopy((char *)FileFormat, "\pAIFF");
  741.             break;
  742.         case    FLOAT:
  743.             PstringCopy((char *)FileFormat, "\pFLOAT");
  744.             break;
  745.         case    INT16:
  746.             PstringCopy((char *)FileFormat, "\pINT16");
  747.             break;
  748.     }
  749.     
  750.     CreateSoundFile = FALSE;
  751.     RunToPass1 = 0;
  752.     RunToPass2 = 0;
  753.     RunToPass3 = 0;
  754.     switch( RunUpTo) {
  755.         case Synthesize:
  756.             CreateSoundFile = TRUE;
  757.             break;
  758.         case Pass3Test:
  759.             RunToPass3 = 1;
  760.             break;
  761.         case Pass2Test:
  762.             RunToPass2 = 1;
  763.             break;
  764.         case Pass1Test:
  765.             RunToPass1 = 1;
  766.             break;
  767.     }
  768.     
  769.     
  770.     SaveMusic4C_Prefs();
  771. }
  772.  
  773.  
  774.  
  775.